package org.boyan.modules.controller;

import org.boyan.common.api.vo.Result;
import org.boyan.entity.trans.TransCode;
import org.boyan.modules.service.TransCodeService;
import org.boyan.transcode.ExcelToTransCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;


@RestController
@RequestMapping("/transCode")
public class TransCodeController {

    @Autowired
    private TransCodeService transCodeService;

    //导入交易吗excel，自动在数据库中加入transcode
    @PostMapping("/upload")
    public Result importTransCode(MultipartFile file){
        List<TransCode> transCodeList= ExcelToTransCode.getTransCodeList(file);
        int ret=transCodeService.addTransCodeList(transCodeList);
        return Result.OK("导入成功!共计导入"+ret+"条数据");
    }
}
